package cn.tangsihai.hrm.client;

import cn.tangsihai.hrm.domain.Login;
import cn.tangsihai.hrm.dto.LoginAndMealId;
import cn.tangsihai.hrm.util.AjaxResult;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class LoginMealFallbackFactory implements FallbackFactory<AuthClient> {
    @Override
    public AuthClient create(Throwable throwable) {
        return new AuthClient() {
            @Override
            public AjaxResult saveLoginAndMeal(LoginAndMealId loginAndMealId) {
                log.error("认证异常{}", throwable.getMessage());
                return AjaxResult.me().setMessage("认证异常");
            }

            @Override
            public AjaxResult saveLogin(Login login) {
                log.error("认证异常{}", throwable.getMessage());
                return AjaxResult.me().setMessage("认证异常");
            }
        };
    }
}
